Avorion Script API Documentation
Entity Callbacks
Note: Callbacks have to be buffered in certain situations and won't happen immediately. When unregistering a callback during a callback, all callbacks that were buffered during the last frame may still be sent, even though they were unregistered.
callback destinationSectorReady(sectorReady)
Executed when the availability state of the destination sector changes. When the sector is loaded into memory, it's set to true. When the sector is unloaded from memory, because there's no player near it, it's set to false.
Parameters
callback onAIStateChanged(entityId, state)
Executed whenever the AI state of the entity changes
Parameters
state The id of the new state
callback onAllScriptValuesChanged(entityId)
Executed whenever all scripts values of the entity have been changed at once
Parameters
callback onAutoSelected()
Executed when the entity gets selected by the player on the client.
callback onBlockChanged(objectIndex, blockIndex, changeFlags)
Executed whenever the plan of the entity is changed.
Parameters
blockIndex The index of the block
changeFlags The flags of the block changes
callback onBlockDamaged(objectIndex, blockIndex, inflictorId, damage, damageType)
Executed whenever a block object is damaged in the sector. This callback is executed after the damage is dealt to the block. Don't remove the block in this callback, this will lead to a crash.
Parameters
blockIndex The index of the damaged block
inflictorId The id of the entity that inflicted the damage
damage The damage that was inflicted to the entity
damageType The type of damage
callback onBlockDestroyed(objectIndex, index, block, lastDamageInflictor, damageSource)
Executed whenever a block of the block object got destroyed This callback is executed *after* the block was destroyed
Parameters
index Index of the block
block The block (as removed from the plan)
lastDamageInflictor The index of the last entity that inflicted damage to the destroyed block
damageSource The source of damage
callback onBlockHealed(objectIndex, blockIndex, damage)
Executed whenever a block of the entity is healed. Don't remove the block in this callback, this will lead to a crash.
Parameters
blockIndex The index of the healed block
damage The damage the entity was healed for
callback onBlockPlanChanged(objectIndex, allBlocksChanged)
Executed whenever the plan of the entity is changed.
Parameters
allBlocksChanged A boolean that indicates whether all the blocks in the block plan have potentially changed
callback onBlocksAdded(objectIndex, wasRepaired, blockIndices)
Executed whenever new block are added to the entity. This callback is executed after the blocks were added.
Parameters
wasRepaired true if the callback was fired because of a repair operation, false otherwise
blockIndices The indices of the added blocks, as variable arguments list
callback onBlocksRemove(objectIndex, blockIndices)
Executed whenever a block will be removed from the plan by building (instead of combat). This callback is executed before the block is removed. IMPORTANT! This only fires on blocks that the player directly chose to be removed. Blocks that get removed because they don't have a connection to the root block any more get signalled after removal by 'onBlocksRemoved'.
Parameters
blockIndices The indices of the removed blocks, as variable arguments list
callback onBlocksRemoved(objectIndex, blockIndices)
Executed whenever a block is removed from the plan by building (instead of combat). This callback is executed after the block is removed.
Parameters
blockIndices The indices of the removed blocks, as variable arguments list
callback onBoardersDefeated(entityId, attackingFaction)
Executed whenever all boarders were defeated
Parameters
attackingFaction The index of the attacking faction
callback onBoardersLand(entityId, attackingFaction, firstLanding)
Executed when boarders land on an entity
Parameters
attackingFaction The index of the attacking faction
firstLanding True if these are the first boarders, false otherwise
callback onBoardingFight(entityId, attackingFaction)
Executed on every round of fighting with boarders
Parameters
attackingFaction The index of the attacking faction
callback onBoardingSuccessful(entityId, oldFactionIndex, newFactionIndex)
Executed whenever an entity was boarded successfully
Parameters
oldFactionIndex The index of the faction that owned the entity before boarding
newFactionIndex The index of the attacking faction that now owns the entity
callback onBreak(objectIndex, plan...)
Executed when the plan of the entity breaks. This callback is executed after the block broke. This callback is expensive, don't register for it if you don't absolutely need it.
Parameters
plan... The plans of the broken off parts
callback onCaptainChanged(index, captain)
Executed whenever the captain of an entity in the sector changes. This callback is executed *after* the captain changed on the entity.
Parameters
captain The new captain (nil if none) of the entity
callback onCaptainChanged(index, captain)
Executed whenever the captain of the entity changes. This callback is executed *after* the captain changed on the entity.
Parameters
captain The new captain (nil if none) of the entity
callback onCargoChanged(objectIndex, delta, good)
Executed whenever the cargo of an entity in the sector changes. This callback is executed *after* the cargo was changed on the entity.
Parameters
delta The amount of cargo that changed
good The good that changed
callback onCargoLootCollected(collector, lootIndex, amount, good, owner)
Executed whenever trading good loot gets collected by a player
Parameters
lootIndex The index of the collected loot
amount The amount of goods that were collected
good The good that was inside the loot entity
owner The original owner of the cargo
callback onCollision(objectIndexA, objectIndexB, damageA, damageB, steererA, steererB)
Executed whenever two block objects collided in the sector
Parameters
objectIndexB The index of the other colliding object
damageA The damage that is inflicted to object A
damageB The damage that is inflicted to object B
steererA The steerer ID of objectA. When an object is docked, not the object itself but the steerer is the one responsible for collisions
steererB The steerer ID of objectB. When an object is docked, not the object itself but the steerer is the one responsible for collisions
callback onCraftSeatEntered(entityId, seat, playerIndex, firstPlayer)
Executed whenever a player enters an empty craft or the last player exits it
Parameters
seat The seat index
playerIndex The index of the player that entered the seat
firstPlayer A bool indicating whether the craft's seats were empty before
callback onCraftSeatLeft(entityId, seat, playerIndex, playersRemaining)
Executed whenever a player enters an empty craft or the last player exits it
Parameters
seat The seat index that was previously occupied
playerIndex The index of the player that left the seat
playersRemaining A bool indicating whether there are still players on the craft
callback onCrewChanged(index, delta, profession)
Executed whenever the crew of an entity in the sector changes. This callback is executed *after* the crew was changed on the entity.
Parameters
delta The amount of crewmen that changed
profession The profession of the crew that changed
callback onCrewChanged(index)
Executed whenever the crew of the entity changes. This callback is executed *after* the crew was changed on the entity.
Parameters
callback onCrewLootCollected(collector, lootIndex)
Executed whenever trading good loot gets collected by a player
Parameters
lootIndex The index of the collected loot
callback onDamaged(objectIndex, amount, inflictor, damageSource, damageType)
Executed whenever an entity is damaged in the sector.
Parameters
amount The amount of damage that was dealt
inflictor The id of the entity that dealt the damage
damageSource The source of damage
damageType The type of damage
callback onDestroyed(index, lastDamageInflictor)
Executed when the entity was destroyed
Parameters
lastDamageInflictor The index of the last entity that inflicted damage to the destroyed entity
callback onDockedByEntity(dockeeId, dockerId)
Executed whenever this entity was docked to another entity
Parameters
dockerId The id of the docking entity (parent)
callback onEntityDocked(dockerId, dockeeId)
Executed whenever an entity docks to another entity
Parameters
dockeeId The id of the entity that was docked (child)
callback onEntityUndocked(dockerId, dockeeId)
Executed whenever an entity undocks from another entity
Parameters
dockeeId The id of the entity that was docked (child)
callback onFighterAdded(entityId, squadIndex, fighterIndex, landed)
Executed whenever a fighter is added to the entity
Parameters
squadIndex The index of the squad
fighterIndex The index of the fighter in the squad
landed A boolean whether the fighter landed or got added otherwise
callback onFighterLanded(entityId, squadIndex, fighterId)
Executed whenever a fighter starts from a hangar of the entity
Parameters
squadIndex The index of the squad
fighterId The id of the fighter that landed
callback onFighterRemove(entityId, squadIndex, fighterIndex, started)
Executed whenever a fighter is removed from the entity, before it gets removed
Parameters
squadIndex The index of the squad
fighterIndex The index of the fighter in the squad
started A boolean whether the fighter started or got removed otherwise
callback onFighterRemoved(entityId, squadIndex, fighterIndex, started)
Executed whenever a fighter is removed from the entity, after it got removed
Parameters
squadIndex The index of the squad
fighterIndex The index of the fighter in the squad
started A boolean whether the fighter started or got removed otherwise
callback onFighterStarted(entityId, squadIndex, fighterId)
Executed whenever a fighter starts from a hangar of the entity
Parameters
squadIndex The index of the squad
fighterId The id of the fighter that started
callback onHealed(objectIndex, amount, inflictor)
Executed whenever an entity is healed in the sector.
Parameters
amount The amount of damage that was healed
inflictor The id of the entity that dealt the damage
callback onHullHit(objectIndex, blockIndex, shooterIndex, damage, location)
Executed whenever a block object is hit by a shot in the sector. Don't delete the block that is hit by the shot, this will lead to a crash.
Parameters
blockIndex The index of the block that was hit by the shot
shooterIndex The index of the craft that fired the shot
damage The damage the shot dealt to the object
location The impact location
callback onHyperspaceEntered(entityId, dx, dy)
Executed whenever an entity in the sector jumps into hyperspace. Won't be triggered when changing sector through background simulation, death, or gate/wormholes.
Parameters
dx X coordinate of the destination
dy Y coordinate of the destination
callback onHyperspaceEntered(entityId, dx, dy)
Executed whenever the entity jumps into hyperspace. Won't be triggered when changing sector through background simulation, death, or gate/wormholes.
Parameters
dx X coordinate of the destination
dy Y coordinate of the destination
callback onInventoryItemLootCollected(collector, lootIndex)
Executed whenever inventory item loot gets collected by
Parameters
lootIndex The index of the loot that was collected
callback onJump(shipId, x, y, sectorChangeType)
Executed whenever the entity jumps into another sector.
Parameters
x The x coordinate of the target sector
y The y coordinate of the target sector
sectorChangeType SectorChangeType enum what kind of sector change it is
callback onJumpRouteCalculationStarted(playerIndex, destinationX, destinationY)
Executed whenever a player starts a new hyperspace jump route calculation
Parameters
destinationX The x-coordinate of the destination sector
destinationY The y-coordinate of the destination sector
callback onLootCollected(collector, lootIndex)
Executed whenever loot gets collected by anyone, be it player or AI faction
Parameters
lootIndex The index of the collected loot
callback onMaterialLootCollected(collector, lootIndex, materialType, value)
Executed whenever material loot gets collected by
Parameters
lootIndex The index of the loot that was collected
materialType The type of material contained in the loot
value The amount of material the loot contained
callback onMoneyLootCollected(collector, lootIndex, value)
Executed whenever money loot gets collected by the entity
Parameters
lootIndex The index of the collected loot
value The amount of credits the loot contained
callback onPassengerAdded(index, passenger)
Executed whenever a passenger is added to an entity in the sector. This callback is executed *after* the passenger was added.
Parameters
passenger The passenger
callback onPassengerAdded(index, passenger)
Executed whenever a passenger is added to the entity. This callback is executed *after* the passenger was added.
Parameters
passenger The passenger
callback onPassengerRemoved(index, passenger)
Executed whenever a passenger is removed from an entity in the sector. This callback is executed *after* the passenger was removed.
Parameters
passenger The passenger
callback onPassengerRemoved(index, passenger)
Executed whenever a passenger is removed to the entity. This callback is executed *after* the passenger was removed.
Parameters
passenger The passenger
callback onPassengersRemoved(index, amount)
Executed whenever passengers are removed from the entity. This callback is executed *after* the passengers were removed.
Parameters
amount Amount of removed passengers
callback onPassengersRemoved(index, amount)
Executed whenever passengers from an entity in the sector are removed. This callback is executed *after* the passengers were removed.
Parameters
amount Amount of removed passengers
callback onPlanModifiedByBuilding(shipIndex)
Executed whenever the plan of an entity was modified by building, meaning adding or removing blocks.
Parameters
callback onScriptAdded(entityId, scriptIndex, scriptPath)
Executed whenever a script was added to the entity
Parameters
scriptIndex The index of the new script
scriptPath The path of the new script
callback onScriptRemoved(entityId, oldScriptIndex, scriptPath)
Executed after a script was removed from the entity
Parameters
oldScriptIndex The old index of the script that was removed
scriptPath The path of the old script
callback onScriptValueChanged(entityId, name, value)
Executed whenever a script value of the entity was changed
Parameters
name The name of the value
value The new value
callback onSectorEntered(entityId, x, y)
Executed whenever the entity enters a sector.
Parameters
x Sector X coordinates of the entered sector
y Sector Y coordinates of the entered sector
callback onSelected()
Executed when the entity gets selected by the player on the client.
callback onSetForDeletion(entityId, deletionType)
Executed whenever the entity is to be deleted.
Parameters
deletionType The deletion type
callback onShaftAutomaticLoadingTypeAssign(entityId, shaftIndex, type)
Executed whenever the torpedo type that is automatically loaded into a shaft was assigned
Parameters
shaftIndex The index of the torpedo shaft
type The type of torpedo that now gets automatically loaded
callback onShaftWeaponIndexAssign(entityId, shaftIndex, weaponIndex)
Executed whenever a torpedo shaft was assigned a new weapon index
Parameters
shaftIndex The index of the new torpedo shaft
weaponIndex The new weapon index of the shaft
callback onShieldActivate(entityId)
Executed whenever the entities shield activates
Parameters
callback onShieldDamaged(entityId, amount, damageType, inflictorId)
Executed whenever the entities shield is damaged
Parameters
amount The amount of damage inflicted
damageType The type of damage dealt
inflictorId The id of the entity that inflicted the damage
callback onShieldDeactivate(entityId)
Executed whenever the entities shield deactivates
Parameters
callback onShieldHealed(entityId, amount)
Executed whenever the entities shield is healed
Parameters
amount The amount of damage healed
callback onShieldHit(objectIndex, shooterIndex, damage, location)
Executed whenever an object's shield is hit by a shot in the sector.
Parameters
shooterIndex The index of the craft that fired the shot
damage The damage the shot dealt to the object
location The impact location
callback onShotFired(entityId)
Executed whenever the entity fires a shot
Parameters
callback onShotHit(objectIndex, shooterIndex, location)
Executed whenever a block object is hit by a shot in the sector.
Parameters
shooterIndex The index of the craft that fired the shot
location The impact location
callback onSquadAdded(entityId, index)
Executed whenever a squad is removed from the entity
Parameters
index The index of the squad
callback onSquadOrdersChanged(entityId, squadIndex, orders, targetId)
Executed whenever the orders of a squad of the entity change
Parameters
squadIndex The index of the squad
orders The orders of the squad
targetId The target assigned to the fighters
callback onSquadRemove(entityId, index)
Executed whenever a squad is removed from the entity, before the squad gets removed
Parameters
index The index of the squad
callback onSquadRemoved(entityId, index)
Executed whenever a squad is removed from the entity, after the squad got removed
Parameters
index The index of the squad
callback onStartDialog(objectIndex)
Executed when a dialog is started.
Parameters
callback onStartFiring(entityId)
Executed whenever the entity starts firing
Parameters
callback onStopFiring(entityId)
Executed whenever the entity stops firing
Parameters
callback onSystemsChanged(shipIndex)
Executed whenever the systems of a ship in the sector changed. This callback is executed *after* the system was changed on the entity.
Parameters
callback onSystemUpgradeLootCollected(collector, lootIndex)
Executed whenever system upgrade loot gets collected by
Parameters
lootIndex The index of the loot that was collected
callback onTorpedoAdded(entityId, shaftIndex, torpedoIndex, torpedo)
Executed whenever a torpedo added to the entity
Parameters
shaftIndex The index of the new torpedo shaft (-1 if storage)
torpedoIndex The index of the torpedo
torpedo The torpedo that's added
callback onTorpedoHit(objectIndex, shooterIndex, torpedoIndex)
Executed whenever a block object is hit by a torpedo in the sector.
Parameters
shooterIndex The index of the craft that fired the torpedo
torpedoIndex The index of the torpedo that hit the object
callback onTorpedoHullHit(objectIndex, blockIndex, shooterIndex, damage, torpedoIndex)
Executed whenever a block object is hit by a torpedo in the sector. Don't delete the block that is hit by the torpedo, this will lead to a crash.
Parameters
blockIndex The index of the block that was hit by the torpedo
shooterIndex The index of the craft that fired the torpedo
damage The damage the torpedo dealt to the object
torpedoIndex The index of the torpedo that hit the object
callback onTorpedoLaunched(entityId, torpedoId)
Executed whenever a torpedo was launched from the entity
Parameters
torpedoId The id of the launched torpedo
callback onTorpedoRemove(entityId, shaftIndex, torpedoIndex)
Executed whenever a torpedo is about to be removed from the entity
Parameters
shaftIndex The index of the new torpedo shaft (-1 if storage)
torpedoIndex The index of the torpedo
callback onTorpedoRemoved(entityId, shaftIndex, torpedoIndex)
Executed whenever a torpedo was removed from the entity
Parameters
shaftIndex The index of the new torpedo shaft (-1 if storage)
torpedoIndex The index of the torpedo
callback onTorpedoShieldHit(objectIndex, shooterIndex, damage, torpedoIndex)
Executed whenever an object's shield is hit by a torpedo in the sector.
Parameters
shooterIndex The index of the craft that fired the torpedo
damage The damage the torpedo dealt to the object
torpedoIndex The index of the torpedo that hit the object
callback onTorpedoStorageChanged(entityId, storage)
Executed whenever the torpedo storage of the entity changed
Parameters
storage The new amount of storage available
callback onTurretAdded(shipIndex, turretIndex)
Executed whenever a turret of the entity was added
Parameters
turretIndex The index of the turret
callback onTurretDestroyed(turretIndex, shipIndex, lastDamageInflictor)
Executed whenever a turret of the entity was destroyed
Parameters
shipIndex The id of the entity that turret was attached to
lastDamageInflictor The index of the last entity that inflicted damage to the destroyed entity
callback onTurretLootCollected(collector, lootIndex)
Executed whenever turret loot gets collected by the entity
Parameters
lootIndex The index of the collected loot
callback onTurretRemoved(shipIndex, turretIndex)
Executed whenever a turret of the entity was removed
Parameters
turretIndex The index of the turret
callback onTurretRemovedByPlayer(shipIndex, turretIndex)
Executed whenever a turret of the entity was removed by the player
Parameters
turretIndex The index of the turret
callback onUndockedFromEntity(dockeeId, dockerId)
Executed whenever this entity was undocked from another entity
Parameters
dockerId The id of the docking entity (parent)
Callbacks Alliance [Client] Callbacks Alliance [Server] Callbacks Alliance [Server] Callbacks Entity Callbacks Galaxy Callbacks Player Callbacks Player [Client] Callbacks Sector Callbacks Server Callbacks
Command Entity FactionDatabase PlanGenerator Player Sector Server UsableInventoryItem
Boarding BspTree CargoBay CargoLoot ControlUnit CrewComponent DeletionTimer DirectFlightPhysics DockingClamps DockingParent DockingPositions Durability EnergySystem Engine FighterAI Hangar HyperspaceEngine InteractionText InventoryItemLoot Owner Physics Plan ReadOnlyBoarding ReadOnlyBspTree ReadOnlyCargoBay ReadOnlyControlUnit ReadOnlyCrew ReadOnlyDeletionTimer ReadOnlyEnergySystem ReadOnlyEngine ReadOnlyFighterAI ReadOnlyHangar ReadOnlyHyperspaceEngine ReadOnlyInteractionText ReadOnlyOwner ReadOnlyPhysics ReadOnlyPlan ReadOnlyShipAI ReadOnlyShipSystem ReadOnlyTorpedoAI [Server] [Client] [Server] [Client] ReadOnlyTorpedoAI [Server] [Client] [Server] [Client] ReadOnlyTorpedoLauncher ReadOnlyTurretBases ReadOnlyVelocity ReadOnlyWeapons ReadOnlyWormHole Shield ShipAI ShipSystem StructuralIntegrity SystemUpgradeLoot Thrusters Torpedo TorpedoAI TorpedoLauncher Turret TurretAI TurretBases Velocity Weapons WormHole
AllianceMember AllianceRank BlockPlan BlockPlanBlock BlockStatistics Box Captain Color ControlUnitSeat CraftDesign CraftStatsOverview Crew CrewMan CrewProfession DebugInfo dvec2 dvec3 dvec4 Entity EntityDescriptor FighterTemplate Format GameSettings Group HighResolutionTimer Inventory InventoryTurret ivec2 ivec3 ivec4 Language Mail Material Matrix ModManager NamedFormat PlanBspTree PlanetSpecifics PlanGenerationStage PlanPart PlanStyle PlayerId PluralForm Profiler QuadTree Random Rarity Ray ReadOnlyEntity Rect Relation Scenario SectorView Seed Sphere Squad SystemUpgradeTemplate Timer Tooltip TooltipLine TorpedoShaft TorpedoTemplate TradingGood TurretDesign TurretDesignPart TurretTemplate UsableInventoryItem Uuid VanillaInventoryItem vec2 vec3 vec4 Version Weapon
EntityIcon EntityTooltip PlanMesh ReadOnlyIcon ReadOnlyPlanMesh ReadOnlyScriptUI ReadOnlyTooltip ScriptUI
Achievements Alliance [Client] CameraKeyFrame CaptainSelectionItem Client ClientSettings ColorSelectionItem CraftDesignSelectionItem Faction [Client] Galaxy [Client] GalaxyMap GameInput GlowFX IconSelectionItem InputWindow InventoryReferenceSelectionItem InventorySelectionItem Keyboard LaserFX Mouse Music PixelIconSelectionItem Planet Player [Client] PlayerWindow RefractionFX Sector [Client] SelectionItem ShipDatabaseEntry [Client] SoundSource StrategyState TargetIndicator TooltipRenderer TurretDesignSelectionItem
AllianceEmblem AllianceTab ArrowLine Button [Client] [Client] Button [Client] [Client] CaptainIcon CaptainProfile CheckBox ComboBox ContextMenu CraftPortrait CrewBar Frame Hud InventorySelection Label Line ListBox ListBoxEx MapArrowLine MapIcon MultiLineTextBox NumbersBar Picture PlanDisplayer ProgressBar SavedDesignsSelection ScrollFrame Selection ShipWindow Slider StatisticsBar Tab TabbedWindow TextBox TextField TooltipDisplayer Tree UIArbitraryHorizontalSplitter UIArbitraryVerticalSplitter UIContainer UIElement UIGridSplitter UIHorizontalLister UIHorizontalMultiSplitter UIHorizontalSplitter UIOrganizer UIRect UIRenderer UIVerticalLister UIVerticalMultiSplitter UIVerticalSplitter ValueComboBox Window
EntityTransferrer FighterController Loot ReadOnlyEntityTransferrer ReadOnlyFighterController ReadOnlyLoot ReadOnlyTurretController ReadOnlyWreckageCreator TurretController WreckageCreator
Alliance [Server] Faction [Server] Galaxy [Server] Player [Server] ReadOnlySector Sector [Server] Server ShipDatabaseEntry [Server]
AIState AlliancePrivilege BeamShape BlockShading BlockStructure BlockType BlockType2 BoxType BuildError CaptainGenderId ChatChannel ChatMessageType ComponentType ControlAction ControlActionBit ControlStyle CoolingType CraftStatsOverviewStat CrewProfessionType CrewRank DamageSource DamageType DeletionType Difficulty EntityArrivalType EntityType FighterOrders FighterStartError FighterType FontType ImpactParticles InventoryItemType JumpError KeyboardKey ListBoxEntryType MalusReason MaterialType MoonType MouseButton PlanetType PlayerStateType ProjectileShape RarityType RelationStatus SavedDesignType ScenarioType SectorChangeType ShipAvailability SoundType StatsBonuses TargetIndicatorVisuals TransformationFeature TurretAutoFireMode TurretSlotType WeaponAppearance WeaponCategory
This is the official documentation for the scripting API of Avorion. This documentation is automatically generated and not necessarily complete. Depending on the context in which functions exist, some documentation such as descriptions, return values or variable names or types may be missing.
Work in Progress. Documentation of Avorion Version: 2.5.7 c8e4beec84f7